package xiajie

class GrandFather(var name:String)
class Father(name:String) extends GrandFather(name)
class Son(name:String)extends Father(name)

object XiaJieDemo {
  def getCard[R >: Son](person:R): Unit ={
    val grandFather = person.asInstanceOf[GrandFather]
    println(grandFather.name + ":拿到卡")
  }
  def main(args: Array[String]): Unit = {
    getCard(new GrandFather("grandfather"))
    getCard(new Father("father"))
    getCard(new Son("Son"))
  }
}
